
$(document).ready(function () {
    var date = new Date()
    var TestData = { Training:{12:2, 25:1, 41:1, 42:1},Healthy:{12:2, 24:2, 31:1, 42:1}}
    var CardDic = {WeekRow1_Day0:"",WeekRow1_Day1:"",WeekRow1_Day2:"",WeekRow1_Day3:"",WeekRow1_Day4:"",WeekRow1_Day5:"",
    WeekRow2_Day0:"",WeekRow2_Day1:"", WeekRow2_Day2:"",WeekRow2_Day3:"",WeekRow2_Day4:"",WeekRow2_Day5:"",
    WeekRow3_Day0:"", WeekRow3_Day1:"", WeekRow3_Day2:"", WeekRow3_Day3:"", WeekRow3_Day4:"", WeekRow3_Day5:"",
    WeekRow4_Day0:"", WeekRow4_Day1:"", WeekRow4_Day2:"", WeekRow4_Day3:"", WeekRow4_Day04:"", WeekRow4_Day5:"",
    WeekRow5_Day0:"", WeekRow5_Day1:"", WeekRow5_Day2:"", WeekRow5_Day3:"", WeekRow5_Day4:"", WeekRow5_Day5:"",
    WeekRow6_Day0:"", WeekRow6_Day1:"", WeekRow6_Day2:"", WeekRow6_Day3:"", WeekRow6_Day4:"", WeekRow6_Day5:"",}



    var MonthDayNum = {0 :31, 1:28, 2:31, 3: 30, 4:31, 5:30, 6: 31, 7:31, 8:30, 9:31, 10:30, 11:31 }

    if(document.getElementById("DayCardsPad") != null){
        console.log("The Bool Result is", $("#DayCardsPad") != null)
        WeekWord = ['周一', '周二', '周三', '周四', '周五', '周末']
        WeekNum = [1, 1, 1, 1, 1,2]
        var YearSwitcherOptions = document.getElementById("CalenderYear").options
        var MonthSwitcher = document.getElementById("CalenderMonth").options
        for(ii = 0; ii < YearSwitcherOptions.length; ii++){
            if(YearSwitcherOptions[ii].value == date.getFullYear().toString()){
                console.log("the value is",YearSwitcherOptions[ii].value,"the Year is",date.getFullYear().toString() )
                YearSwitcherOptions[ii].selected = true
            }else {
                YearSwitcherOptions[ii].selected = false
            }
        }
        for(ii = 0; ii<MonthSwitcher.length; ii++){
            if(MonthSwitcher[ii].value == date.getMonth().toString()){
                console.log("the value is",MonthSwitcher[ii].value,"the Month is",date.getMonth().toString() )
                MonthSwitcher[ii].selected = true
            }else {
                MonthSwitcher[ii].selected = false
            }
        }

        var DayCardsPad = document.getElementById("DayCardsPad")
        for(var i = 0; i<5; i++){
            var WeelRow = document.createElement("div")
            WeelRow.setAttribute('class', 'row')
            WeelRow.setAttribute('id', 'WeekRow'+i.toString())
            flag = 0
            for(var j = 0; j<6; j++){
                // 设置日期卡片
                var DayCard = document.createElement('div')
                var DayCardCol = document.createElement("div")
                DayCardCol.setAttribute('class', 'col-md-2')
                DayCard.setAttribute('class', 'DayCard')
                DayCard.setAttribute('id', 'WeekRow'+(i+1).toString()+'_Day'+j.toString())
                //设置日期卡片标题
                var DayCardTitle = document.createElement('div')
                DayCardTitle.setAttribute('id', 'WeekRow'+i.toString()+'_DayTitle'+j.toString())
                DayCardTitle.setAttribute('class', 'DayCardTitle')
                DayCardTitle.innerText = WeekWord[j]
                //设置日期卡片内容
                var DayCardItemRow = document.createElement("div")
                DayCardItemRow.setAttribute('class', 'row')
                var DayCardItemOne = document.createElement("div")
                DayCardItemOne.setAttribute('class', 'DayCardItem col-md-12')
                DayCardItemOne.setAttribute('id', 'DayCardItem'+i.toString()+'_'+j.toString()+'ItemOne')
                var DayCardItemTwo = document.createElement("div")
                DayCardItemTwo.setAttribute('class', 'DayCardItem col-md-12')
                DayCardItemTwo.setAttribute('id', 'DayCardItem'+i.toString()+'_'+j.toString()+'ItemTwo')
                DayCard.appendChild(DayCardTitle)
                DayCardItemOne.setAttribute('onclick',"ShowDayCardOneDetail("+(i+1).toString()+"_"+j.toString()+")")
                DayCardItemTwo.setAttribute('onclick',"ShowDayCardTwoDetail("+(i+1).toString()+"_"+j.toString()+")")

                //根据ajax回传的数据进行日期卡片的设置
                if( TestData["Training"][i.toString()+j.toString()] != null){
                    DayCardItemOne.innerText = "有"+TestData["Training"][i.toString()+j.toString()]+'项职业培训'
                }
                if( TestData["Healthy"][i.toString()+j.toString()] != null){
                    DayCardItemTwo.innerText = "有"+TestData["Healthy"][i.toString()+j.toString()]+'项健康检查'
                }

                DayCard.appendChild(DayCardItemOne)
                DayCard.appendChild(DayCardItemTwo)
                DayCardCol.appendChild(DayCard)
                WeelRow.appendChild(DayCardCol)
                flag = flag + 1
            }
            DayCardsPad.appendChild(WeelRow)
        }
    }
    $.parser
}
)

$(function() {
    $('#Start_Time').datetimepicker({
    });
  });

  $(function() {
    $('#End_Time').datetimepicker({
    });
  });